<template>
    <div class="padding20">
        <el-upload
                :limit="2"
                :on-remove="uploadRemoveLogo"
                :on-change="uploadChangeLogo"
                :file-list="fileListLogo"
                :auto-upload="false"
                action="string"
                list-type="picture-card">
            <i class="el-icon-plus"></i>
        </el-upload>

    </div>
</template>

<script lang="ts">
    import {Component} from 'vue-property-decorator'
    import Pagination from "@/components/Pagination/Pagination.vue";
    import BaseSysVue from "@/utils/BaseSysVue";
    import {ElForm} from "element-ui/types/form";
    import {API} from "@/aconst/API";
    import {errorMsg} from "@/utils/message";
    import $http from "@/http";
    import BaseVue from "@/utils/BaseVue";

    @Component({
        name: 'File',
        components: {
            Pagination
        },
    })
    export default class File extends BaseVue {
        fileListLogo: any = [];

        // 需要修改 logo
        uploadChangeLogo(file: any, fileList: any) {
            let formData = new FormData();
            fileList.forEach((file: any) => {
                if (file.raw instanceof Blob) {
                    formData.append("files", file.raw, file.name);
                }
            });
            formData.append("type", "11");
            let config: any = {'Content-Type': 'multipart/form-data'};
            return $http.post("/sbWeb/api/declare/uploadFile", formData, config).then((res: any) => {
                // return $http.post("/superman/file/upload", formData, config).then((res: any) => {
                if (res.success) {
                    this.fileListLogo = [];
                    for (let a of res.data) {
                        // this.fileListLogo.push({url: "http://127.0.0.1:8099" + a['url']});
                        this.fileListLogo.push({url: a['imgUrl']});
                        // this.fileListLogo.push({url: a['url']});
                    }
                    return true;
                } else {
                    return false;
                }
            });
        }

        //需要修改 logo
        uploadRemoveLogo(file: any, fileList: any) {
            this.fileListLogo = fileList;
        }


    }


</script>

<style scoped>

</style>
